package com.enjoyor.soa.traffic.core.tpcms.mapper.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.enjoyor.soa.traffic.api.dto.tpcms.PassCardDto;
import com.enjoyor.soa.traffic.core.tpcms.constant.PassCardSqlId;
import com.enjoyor.soa.traffic.core.tpcms.domain.PassCard;
import com.enjoyor.soa.traffic.core.tpcms.mapper.IPassCardMapper;
import com.enjoyor.soa.traffic.frame.support.mybatis.mapper.impl.BaseMapper;

@Service
@Transactional
public class PassCardMapper extends BaseMapper<PassCard> implements IPassCardMapper {

    /*
     * @Override public void insert(PassCard passCard) {
     * passCard.setPassCardId("P" + String.valueOf(System.nanoTime()));
     * passCard.setCreateTime(new Date()); super.insert(passCard); }
     */

    @Override
    public List<PassCard> getPassCardList(Map<String, Object> map) {
        return sqlSessionTemplate.selectList(getSqlName(PassCardSqlId.SQL_SELECT_LIST), map);
    }

    @Override
    public List<PassCardDto> getPassCardDetailList(Map<String, Object> map) {
        return sqlSessionTemplate.selectList(getSqlName(PassCardSqlId.SQL_SELECT_DETAIL_LIST), map);
    }

    @Override
    public List<PassCard> getAllPassTrucks() {
        Map<String, Object> map = new HashMap<String, Object>();
        return sqlSessionTemplate.selectList(getSqlName(PassCardSqlId.SQL_SELECT_ALLTRUCKS), map);
    }

    @Override
    public List<PassCard> getAllTrucksByRoadId(String stopRoadId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("stopRoadId", stopRoadId);
        return sqlSessionTemplate.selectList(getSqlName(PassCardSqlId.SQL_SELECT_ALLTRUCKS_ROADID), map);
    }

    @Override
    public PassCard getMaxPassCardId() {
        Map<String, Object> map = new HashMap<String, Object>();
        return sqlSessionTemplate.selectOne(getSqlName(PassCardSqlId.SQL_SELECT_MAX_PASSCARDID), map);
    }

}
